<html>
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		function newDoc(){
			window.location.assign("http://www.w3school.com.cn")
		}

		function goBack(){
			history.back()
		}

		function goForward(){
			history.forward()
		}

		function disp_confirm(){
			var r=confirm("Press a button")
			if (r==true) {
				document.write("You pressed OK!")
			}
			else{
				document.write("You pressed Cancel!")
			}
		}

		var c=0
		var t

		function timedCount(){
			document.getElementById("txt").value=c
			c=c+1
			t=setTimeout("timedCount()",1000)
		}

		function stopCount(){
			clearTimeout(t)
		}

		function getCookie(c_name){
			if (document.cookie.length>0) {
				c_start=document.cookie.indexof(c_name + "=")
				if (c_start!=1) {
					c_start=c_start + c_name.length+1
					c_end=document.cookie.indexof(";",c_start)
					if (c_end==-1) {
						c_end=document.cookie.length
					}
						return unescape(document.cookie.substring(c_start,c_end))
				}
			}
			return ""
		}

		function setCookie(c_name,value,expiredays){
			var exdate=new Date()
			exdate.setDate(exdate.getDate()+expiredays)
			document.cookie=c_name + "=" + escape(value)+((expiredays==null)?"":";expires="+exdate.toGMTString())
		}

		function checkCookie(){
			username=getCookie('username')
			if (username!=null && username!="") {
				alert('Welcome again '+username+'!')
			}
			else{
				username=prompt('Please enter your name:',"")
				if (username!=null && username!="") {
					setCookie('username',username,365)
				}
			}
		}


	</script>
</head>
<body onLoad="checkCookie()">
	<p id="demo"></p>
	<input type="button" name="" value="加载新文档" onclick="newDoc()">

	<input type="button" name="" value="Back" onclick="goBack()">

	<input type="button" name="" value="Forward" onclick="goForward()">

	<div id="example"></div>

	<input type="button" name="" value="Display a confirm box" onclick="disp_confirm()">

	<form>
		<input type="button" name="" value="Start count!" onclick="timedCount()">
		<input type="text" name="" id="txt">
		<input type="button" name="" value="Stop count!" onclick="stopCount()">
	</form>



	<script type="text/javascript">
		var w=window.innerWidth
		var h=window.innerHeight
		document.getElementById("demo").innerHTML="浏览器的内部窗口宽度：" + w + "，高度：" + h + "。"

		txt="<p>Browser CodeName:" + navigator.appCodeName + "</p>";
		txt+="<p>Browser Name:" + navigator.appName + "</p>";
		txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
		txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
		txt+= "<p>Platform: " + navigator.platform + "</p>";
		txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";
		txt+= "<p>User-agent language: " + navigator.systemLanguage + "</p>";

        document.getElementById("example").innerHTML=txt;



	</script>
</body>
</html>